home *** CD-ROM | disk | FTP | other *** search
- Porting AmigaBase programs to MUIbase programs
- ==============================================
-
- The following is a brief guide on how to port AmigaBase
- programs to MUIbase programs.
-
- Here is a note from Ralph Reuchlein about programming MUIbase:
-
- "Please comment amap (as much as possible ;-) ) in MUIbase programs!
- Because of the crowd of parentheses one should comment every action
- either for himself or for others who have to work with the database."
-
-
- Integer ranges
- ==============
-
- In MUIbase all integer ranges start with zero and end with
- the number of items minus 1. The following section gives a
- more detailed list of all affected structures.
-
- Internal values of CHOICE values
- --------------------------------
-
- In MUIbase internal numbers of CHOICE fields are in the
- range of 0...(num-labels - 1) whereas in AmigaBase they are
- in the range of 1..num-labels.
-
- Character index in strings
- --------------------------
-
- The first character in a MUIbase string has index 0, whereas
- in AmigaBase it has index 1.
-
- Line index in memos
- -------------------
-
- The first line of a MUIbase memo has index 0, whereas in
- AmigaBase it has index 1.
-
-
- String comparison
- =================
-
- When comparing strings in MUIbase by calling (= string1 string2)
- case-sensitive string comparison is used, whereas AmigaBase uses
- case-insensitive string comparison when calling (string1 = string2).
- In MUIbase you can do case-insensitive string comparison by using
- (=* string1 string2)
-
-
- Non-strict functions
- ====================
-
- In MUIbase AND and OR are implemented in a non-strict way, whereas in
- AmigaBase they are strict. Non-strict means that not necessary all arguments
- of the AND or OR expression are evaluated, e.g. in (AND NIL (PRINTF "Hello"))
- no output is done because AND does not need to evaluate the (PRINTF "Hello")
- expression.
-
-
- Table of function equivalents
- =============================
-
- The following gives an overview on how to replace AmigaBase functions
- with MUIbase functions.
-
- A minus sign in the MUIbase column indicates that the corresponding
- AmigaBase function will not be implemented in MUIbase.
-
-
- 1. Program flow control
-
- AmigaBase MUIbase
- ------------------------------------------------------------
- IF expr THEN true-expr (IF expr (true-expr) (false-expr))
- ELSE false-expr
- END
-
- ERROR (ERROR error-string)
- HALT (HALT)
- RETURN (RETURN)
- RETURN(value) (RETURN value)
-
-
- 2. Loops
-
- AmigaBase MUIbase
- ------------------------------------------------------------
- FOR i := 0 TO n-1 DO (DOTIMES (i n) cmds)
- cmds
- END
-
- FOR i := start TO end DO (DO ((i start (1+ i)))
- cmds ((> i end))
- END cmds
- )
-
- FOR i := start TO end (DO ((i start (+ i step)))
- BY step DO ((IF (> step 0)
- cmds (> i end)
- END (< i end)
- ))
- cmds
- )
-
- WHILE expr DO (DO () ((NOT expr)) cmds)
- cmds
- END
-
- WITH ALL Rec DO (FOR ALL Rec DO cmds)
- cmds
- END
-
- WITH ALL Rec1 OF Rec2 DO -
- cmds
- END
-
- EXIT (EXIT)
- NEXT (NEXT)
-
-
- 3. Constants
-
- AmigaBase MUIbase
- ------------------------------------------------------------
- TRUE TRUE
- FALSE NIL
- NIL NIL
- NODATE NIL
- NOTIME NIL
- OFF -
- ON -
-
-
- 4. Conversion functions
-
- AmigaBase MUIbase
- ------------------------------------------------------------
- INTSTR(i) (STR i)
- REALSTR(r, n, e) (IF (= e 0)
- (SPRINTF "%.*f" n r)
- (SPRINTF "%.*e" n r)
- )
- DATESTR(d, s) (IF d (STR d) s)
- TIMESTR(t, s) (IF t (STR t) s)
- MEMOSTR(m, n) (LINE m n)
- CHOICESTR(c) (STR c)
- CHOICEVAL(c) (INT c) or c
- CHOICELABELS(c) (GETLABELS c)
- STR(x) (STR x)
- VAL(x) (REAL x)
- STRTODATE(s) (DATE s)
- STRTOTIME(s) (TIME s)
-
-
- 5. Boolean functions
-
- AmigaBase MUIbase
- ------------------------------------------------------------
- a AND b (AND a b)
- a OR b (OR a b)
- NOT(a) (NOT a)
-
-
- 6. String processing functions
-
- AmigaBase MUIbase
- ------------------------------------------------------------
- LEN(s) (LEN s)
- LEFTSTR(s, n) (LEFTSTR s n)
- RIGHTSTR(s, n) (RIGHTSTR s n)
- MIDSTR(s, p) (MIDSTR s p NIL)
- MIDSTR(s, p, n) (MIDSTR s p n)
- FORMAT(s, n, d) -
- STRSTR(s, n) -
- UPPERSTR(s) (UPPER s)
- LOWERSTR(s) (LOWER s)
- TRIMSTR(s) (TRIMSTR s)
- INDEXSTR(s, t) (INDEXSTR* s t)
- INDEXBRK(s, t) (INDEXBRK* s t)
- SPRINTF(fmt, par, ...) (SPRINTF fmt par ...)
- STRCMP(s, t) (= s t)
- JOKERCMP(s, j) (LIKE s j)
- STRSIZE(s) (MAXLEN s)
-
-
- 7. Memo processing functions
-
- AmigaBase MUIbase
- ------------------------------------------------------------
- MEMOLINES(m) (LINES m)
- MEMOSTR(m, n) (LINE m n)
- MEMOSET(m, s, n) -
- MEMOINS(m, s, n) -
- MEMODEL(m, p, n) -
- MEMOSORT(m) (LISTTOMEMO (SORTLISTGT > (MEMOTOLIST m)))
- MEMOFILL(m) (FILLMEMO m)
- MEMOLOAD(m , filename) - can be replaced by:
- (LET ((file (FOPEN filename "r")))
- (IF (NOT file) (ERROR "Can't open %s" filename))
- (SETQ m (FGETMEMO file))
- (FCLOSE file)
- )
- MEMOSAVE(m, filename) - can be replaced by:
- (LET ((file (FOPEN filename "w")))
- (IF (NOT file) (ERROR "Can't open %s" filename))
- (FPUTMEMO m file))
- (FCLOSE file)
- )
- SHOW(m) (SETWINDOWOPEN m TRUE)
- CLOSE(m) (SETWINDOWOPEN m FALSE)
-
-
- 8. Floating point processing functions
-
- AmigaBase MUIbase
- ------------------------------------------------------------
- TRUNC(r) - (TRUNC r)
- ROUND(r, i) - (ROUND r i)
- VAL(x) (REAL x)
- REALSTR(r, n, e) (IF (= e 0)
- (SPRINTF "%.*f" n r)
- (SPRINTF "%.*e" n r)
- )
-
- 9. Calling other functions
-
- AmigaBase MUIbase
- ------------------------------------------------------------
- CALC(var) (SETQ* var new-value)
- _Func(arg1, ...) (_Func arg1 ...)
- PRENEWDATASET(r)
- POSTNEWDATASET(r) (NEW* r ...)
- PREDELETEDATASET(r)
- POSTDELETEDATASET(r) (DELETE* r ...)
-
- 10. Functions for tables/records
-
- AmigaBase MUIbase
- ------------------------------------------------------------
- NEW(r) (NEW r NIL)
- DELETE(r) (DELETE r NIL)
- ORDER(r) - order is always correct
- GETORDERSTR(r) (GETORDERSTR r)
- SETORDERSTR(r attrs) (SETORDERSTR r attrs)
- SHOW(r) ((SETQ r* r) (SETWINDOWOPEN r TRUE))
- CLOSE(r) (SETWINDOWOPEN r FALSE)
- MATCHFILTER(r) (GETMATCHFILTER r)
- GETFILTER(r) (GETFILTERACTIVE r)
- SETFILTER(r, b) (SETFILTERACTIVE r b)
- GETFILTERSTR(r) (GETFILTERSTR r)
- SETFILTERSTR(r, s) (SETFILTERSTR r s)
- RECNAME(r) (TABLENAME r)
- GETDNUM(r1, r2) (RECNUM r1)¹
- EXISTSDNUM(n, r1, r2) (RECORD r1 n)¹
- EXISTSRELDNUM(n, r1, r2) (RECORD r1 (+ (RECNUM r1) n))¹
- SETDNUM(n, r1, r2) (SETQ r (RECORD r1 n))¹
- SETRELDNUM(n, r1, r2) (SETQ r (RECORD r1 (+ (RECNUM r1 n))))¹
- DNUMS(r1, r2, f) (IF f (RECORDS r1*) (RECORDS r1))¹
- PUSH(record) - (you may use a global variable (list)
- POP(record) - for this purpose).
-
- ¹) Does not match exactly as MUIbase is not hierarchical.
-
-
- 11. Functions for variables/attributes
-
- AmigaBase MUIbase
- ------------------------------------------------------------
- PROTECT(var, flag) (SETDISABLED var flag)
- PEN(var, color) - no front pen colors yet
- VARNAME(var) (ATTRNAME var)
-
-
- 12. Functions for requesting input from the user
-
- AmigaBase MUIbase
- ------------------------------------------------------------
- REQUEST(text, l, m, r) (ASKBUTTON NIL text (LIST l m) r)¹
-
- MULTIREQUEST(text, (ASKBUTTON NIL text (LIST t1 t2 ...) tn)¹
- "t1|t2...tn")
-
- CHOOSEITEM(title, items, (ASKCHOICE title oktext
- oktext) (MEMOTOLIST items) NIL)
-
- CHOOSESTRING(title, items, (ASKCHOICESTR title oktext
- oktext) (MEMOTOLIST items) NIL)
-
- SELECTFILE(title, filename) (ASKFILE title NIL filename TRUE)
-
- INPUT(title, edit) (ASKSTR title NIL edit NIL)
-
- ¹) Return value has different meaning in MUIbase.
-
-
- 13. Functions for output
-
- AmigaBase MUIbase
- ------------------------------------------------------------
- OPENOUTPUT(name, a) (FOPEN name "w") or (FOPEN name "a")
- CLOSEOUTPUT (FCLOSE ...)
- PRINT(s) (PRINTF "%s" s)
- PRINTF(fmt, par, ...) (PRINTF fmt par ...)
- PRINTLN (PRINTF "\n")
- PRINTMEMO(m, t) (DOLIST (s (MEMOTOLIST m))
- (PRINTF "%.*s%s" t "" s)
- )
- RESET (PRINTF RESET)
- DRAFT (PRINTF NLQOFF)
- NLQ (PRINTF NLQON)
- ELITE(f) (PRINTF (IF f ELITEON ELITEOFF))
- NORMAL (PRINTF NORMAL)
- BOLD(f) (PRINTF (IF f BFON BFOFF))
- ITALIC(f) (PRINTF (IF f ITON ITOFF))
- UNDERLINED(f) (PRINTF (IF f ULON ULOFF))
- WIDE(f) (PRINTF (IF f WIDEON WIDEOFF))
- CONDENSED(f) (PRINTF (IF f CONDON CONDOFF))
-
-
- 14. Misc functions
-
- AmigaBase MUIbase
- ------------------------------------------------------------
- CALL(command) (SYSTEM command)
- EXISTS(filename) (STAT filename)
- TODAY (TODAY)
- NOW (NOW)
- BUSY(f) -
- FILENAME -
- CHANGES (CHANGES)
- AREXXPORT - no ARexx interface yet.
-
-